package com.jdls.tanhua.dubbo.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jdls.tanhua.dubbo.QuestionApi;
import com.jdls.tanhua.dubbo.mapper.QuestionMapper;
import com.jdls.tanhua.pojo.Question;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author 嘉德罗斯
 * @date 2021/10/24
 */
@DubboService
public class QuestionApiImpl implements QuestionApi {

    @Autowired
    private QuestionMapper questionMapper;
    @Override
    public Question find(Long id) {
        LambdaQueryWrapper<Question> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Question::getUserId,id);
        Question question = questionMapper.selectOne(queryWrapper);
        return question;
    }

    @Override
    public void save(Question qu) {
        questionMapper.insert(qu);
    }

    @Override
    public void update(Question question) {
        questionMapper.updateById(question);
    }
}
